package com.huike.stock_analysis.controller;



import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import com.huike.stock_analysis.service.RiskService;

/**
 * 
 * @author mzLEI
 * 风险规避分析接口
 */
@RestController
@CrossOrigin(value = "*")
@RequestMapping("/risk")
public class RiskController {
	@Autowired
	private RiskService rService;
	//历史波动率及行业平均
	/*
	@RequestMapping("/historyVibrationRatio")
	public String historyVibrationRatio() {
		Map<String, Double> map = rService.historyRatio("000001");
		ObjectMapper mapper = new ObjectMapper();
		
		String result = "";
		try {
			result = mapper.writeValueAsString(map);
		} catch (JsonProcessingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return result;
	}
	//近20日成交量
	@RequestMapping("/VolOf20")
	public String VolOf20() {
		Map<String, Double> map = rService.Vol20();
		ObjectMapper mapper = new ObjectMapper();
		
		String result = "";
		try {
			result = mapper.writeValueAsString(map);
		} catch (JsonProcessingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return result;
	}
	*/
	
	//Z值分析
	@RequestMapping("/z_test")
	public String zTset(String stock) {
		if(stock == null) return "null";
		return rService.zTest(stock);
	}
	//应收账款占比
	@RequestMapping("/accountsReceivable")
	public String accountsReceivable(String stock) {
		if(stock == null) return "null";
		return rService.accountsReceivable(stock);
	}
	//市盈率
	@RequestMapping("/pe")
	public String pe(String stock) {
		if(stock == null) return "null";
		return rService.pe(stock);
	}
	//市净率
	@RequestMapping("/pb")
	public String pb(String stock) {
		if(stock == null) return "null";
		return rService.pb(stock);
	}
	
	

}
